;(function($){
	$.Resizer=$.Widget.extend({
		init:function(){
			
		}
	});
	$.fn.extend({
		dragResize:function(){
			$(document).bind('mousemove',function(event){
				var $el=$(event.srcElement||event.target),el=this,d=window.__dragObj__;
				if(d&&d.type=='drag'){
					var tmp=d.el.get(0);
					var top=parseInt(tmp.style.top+0), left=parseInt(tmp.style.top+0), x=event.clientX, y=event.clientY;
					d.el.css({top:(top+y-d.y)+'px',left:(left+x-d.x)+'px'});
				}else if(d&&d.type=='resize'){
					var tmp=d.el.get(0), css;
					var top=parseInt(tmp.style.top+0), left=parseInt(tmp.style.top+0), width=parseInt(tmp.style.width+0), height=parseInt(tmp.style.height+0)
						, x=event.clientX, y=event.clientY;
					if($el.hasClass('dragresize-tl')){
						css={top:(top+y-d.y)+'px',left:(left+x-d.x)+'px',width:(width-x+d.x)+'px',height:(height-y+d.y)+'px'};
					}else if($el.hasClass('dragresize-tm')){
						css={top:(top+y-d.y)+'px',height:(height-y+d.y)+'px'};
					}else if($el.hasClass('dragresize-tr')){
						css={top:(top+y-d.y)+'px',width:(width-x+d.x)+'px',height:(height-y+d.y)+'px'};
					}else if($el.hasClass('dragresize-ml')){
						css={left:(left+x-d.x)+'px',width:(width-x+d.x)+'px'};
					}else if($el.hasClass('dragresize-mr')){
						css={width:(width-x+d.x)+'px'};
					}else if($el.hasClass('dragresize-bl')){
						css={top:(top+y-d.y)+'px',left:(left+x-d.x)+'px',width:(width+x-d.x)+'px',height:(height+y-d.y)+'px'};
					}else if($el.hasClass('dragresize-bm')){
						css={height:(height-y+d.y)+'px'};
					}else if($el.hasClass('dragresize-br')){
						css={width:(width+x-d.x)+'px',height:(height+y-d.y)+'px'};
					}
					window.document.title=event.button;
					d.el.css(css);
				}
			});
			$(document).bind('mouseup',function(){
				delete window.__dragObj__;
			});
			return this.each(function(){
				var $this=$(this);
				$this.bind('mousedown',$this,function(event){
					var $el=$(event.srcElement||event.target),el=this;
					var tmp=$el.hasClass('tc_dragable_handler')?$el:$el.parents('.tc_dragable_handler:first');
					delete window.__dragObj__;
					if(tmp&&tmp.size()==1){
						dragObj.mark='drag';
						window.__dragObj__={type:'drag',el:event.data,handler:tmp,x:event.clientX,y:event.clientY};
					}else{
						tmp=$el.hasClass('tc_dragresize_handler')?$el:$el.parents('.tc_dragresize_handler:first');
						if(tmp&&tmp.size()==1){
							window.__dragObj__={type:'resize',el:event.data,handler:tmp,x:event.clientX,y:event.clientY};
						}
					}
				});
				$this.bind('mouseup',function(){
					delete window.__dragObj__;
				});
			});
		}
	});
})(jQuery);